home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zoom 2
/
Zoom - Release 2 (1996)(Active Software)[!].iso
/
misc
/
scion409
/
scionarexx.lha
/
translate.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-09-21
|
11KB
|
347 lines
/****************************************************************************
* *
* $VER: Translate 1.34 (19 Aug 1995)
* *
* Written by Freddy Ariës *
* *
* You may have noticed that setting another language in Locale means that *
* the date (month) fields of your database are no longer recognized *
* correctly. This is where Translate comes in. *
* It will convert all the standard language fields in a Scion database (in *
* v4.0+, that means the Date fields) into another (predefined) language. *
* Currently Dutch, German, French, Italian and Norwegian are supported, *
* but only translation to and from English is possible. Adding other *
* languages shouldn't be hard. *
* *
* This script uses (by default) the rexxreqtools.library (which requires *
* a version of reqtools larger than 2.0 and rexxsyslib.library) *
* If you do not have these, you need to supply the NOREQ argument (for *
* Shell output), or the QUIET argument (for no output at all). *
* *
* Now with progress indicator, using rexxarplib.library (requested by *
* The Great Robbie himself ;-)) *
* *
****************************************************************************/
options results
arg panum outval
versionstr = "1.34"
NL = '0A'x
usereq = 1; /* change this to 0 if you don't want to use reqtools */
outp = 1;
prgrs = 1; pgopen = 0; /* use RexxArp progress indicator */
/* change prgrs to 0 for not using it */
/* parse command line options, to allow calling the script automatically,
* eg. from a function key
*/
do while panum = '?'
Tell("NUMOPT/N,QUIET/S,NOREQ/s: ")
pull panum outval
end
if panum ~= "" then do
if panum = "QUIET" then do
panum = ""; outval = "QUIET"
lang = 0
end
else if panum = "NOREQ" then do
panum = ""; outval = "NOREQ"
lang = 0
end
else do
pnum = C2D(upper(left(panum,1)))
if pnum >= 65 & pnum <= 90 then do
panum = pnum - 64
lang = CheckAnswer(panum)
end
else if pnum > 47 & pnum < 57 then
lang = CheckAnswer(panum)
else do
lang = 0; panum = ""
end
end
end
else
lang = 0
if outval = "QUIET" then do
outp = 0; usereq = 0; prgrs 0
end
else if outval = "NOREQ" then do
usereq = 0; prgrs = 0
end
if usereq & ~show('l','rexxreqtools.library') then do
if exists('libs:rexxreqtools.library') then
call addlib('rexxreqtools.library',0,-30,0)
else do
usereq = 0; outp = 1
Tell("Unable to open rexxreqtools.library - using text output")
end
end
if ~usereq then prgrs = 0
if prgrs & ~show('l','rexxarplib.library') then do
if exists('libs:rexxarplib.library') then
call addlib('rexxarplib.library',0,-30,0)
else
prgrs = 0
end
/* These few lines were stolen from Peter Billings - thanks Peter ;-) */
if ~show('P','SCIONGEN') then do
TermError('I am sorry to say that the SCION Genealogist' || NL ||,
'database is not available. Please start the' || NL ||,
'SCION program BEFORE using this script!')
end
myport = "SCIONGEN"
address value myport
GETDBNAME
dbname = upper(RESULT)
if outp & ~usereq then do
Tell("Translate - Scion Language Fields Converter "||versionstr||" by Freddy Ariës")
Tell("Database: "||dbname|| NL)
end
if lang = 0 then do
if ~outp then
TermError("Missing required argument!")
/* even though you will never get to see the message... */
if usereq then do
answ = rtezrequest('Database: '||dbname || NL ||,
'Please select one of the following conversions: ' || NL || NL ||,
' a) Nederlands -> English g) Italiano -> English' || NL ||,
' b) English -> Nederlands h) English -> Italiano' || NL ||,
' c) Deutsch -> English i) Norsk -> English' || NL ||,
' d) English -> Deutsch j) English -> Norsk' || NL ||,
' e) Français -> English' || NL ||,
' f) English -> Français 0) Abort' ||,
NL, ' _a | _b | _c | _d | _e | _f | _g | _h | _i | _j | _0 ','Translate - Scion Language Field Converter '|| versionstr || ' by Freddy Ariës','rtez_flags=ezreqf_noreturnkey rt_pubscrname=SCIONGEN')
end
else if outp then do
Tell("Please select one of the following conversions: ")
Tell(" a) Nederlands -> English g) Italiano -> English")
Tell(" b) English -> Nederlands h) English -> Italiano")
Tell(" c) Deutsch -> English i) Norsk -> English")
Tell(" d) English -> Deutsch j) English -> Norsk")
Tell(" e) Français -> English")
Tell(" f) English -> Français 0) Abort")
TellNN("Your choice: ")
pull answ
pnum = C2D(upper(left(answ,1)))
if pnum >= 65 & pnum <= 90 then
answ = pnum - 64
end
lang = CheckAnswer(answ)
end
if lang = 0 | answ = 0 then EXIT
if prgrs then do
Postmsg(10, 10, "Scion Translate (by Freddy Ariës)\Database: "||dbname||"\ \ ", "SCIONGEN")
pgopen = 1
end
select
/* Make sure the string in datout is always <= the one in datin, or
* the resulting string might not fit in the date field anymore.
* Note: some 2-letter fields ('CA', 'VR', 'AV') can't follow this rule.
*/
when lang = 1 then do
datin = "MRT MAA MEI OKT CA CA. CIRCA VR VR. VOOR NA"
datout= "Mar Mar May Oct Abt Abt About Bef Bef Bef Aft"
end
when lang = 2 then do
datin = "MAR MAY ABT ABOUT BEF BEFORE AFT AFTER"
datout= "Mrt Mei Ca Circa Vr Voor Na Na"
end
when lang = 3 then do
datin = "MÄR Mär MRZ MAI OKT DEZ CA CA. UNGEFÄHR UNGEFäHR VOR NAC NACH"
datout= "Mar Mar Mar May Oct Dec Abt Abt About About Bef Aft Aft"
end
when lang = 4 then do
datin = "MAR MAY OCT DEC ABT ABOUT BEF BEFORE AFT AFTER"
datout= "Mär Mai Okt Dez Ca Ca Vor Vor Nac Nach"
end
when lang = 5 then do
datin = "FEV FéV FÉV AVR MAI UIN UIL OUT OÛT OûT DéC DÉC ENV ENVIRON AV AVANT APR APRES APRèS APRÈS"
datout = "Feb Feb Feb Apr May Jun Jul Aug Aug Aug Dec Dec Abt About Bef Bef Aft After After After"
end
when lang = 6 then do
datin = "FEB APR MAY JUN JUL AUG DEC ABT ABOUT BEF BEFORE AFT AFTER"
datout= "Fév Avr Mai uin uil oût Déc Env Env Av Avant Apr Après"
end
when lang = 7 then do
datin = "GEN MAG GIU LUG AGO SET OTT DIC INTORNO AL CA. PRIMA PRI DOPO DOP"
datout = "Jan May Jun Jul Aug Sep Oct Dec About . Abt Bef Bef Aft Aft"
end
when lang = 8 then do
datin = "JAN MAY JUN JUL AUG SEP OCT DEC ABOUT ABT BEFORE BEF AFTER AFT"
datout= "Gen Mag Giu Lug Ago Set Ott Dic Ca. Ca. Prima Pri Dopo Dop"
end
when lang = 9 then do
datin = "MAI OKT DES OMKRING CA. FøR FØR ETTER ETT"
datout = "May Oct Dec About Abt Bef Bef After Aft"
end
when lang = 10 then do
datin = "MAY OCT DEC ABOUT ABT BEFORE BEF AFTER AFT"
datout= "Mai Okt Des Ca. Ca. Før Før Etter Ett"
end
otherwise
TermError("Invalid option: "lang)
end
if ~usereq then
Tell("Parsing Personal Details...")
else if pgopen then
Postmsg(,, "\\Processing person:\", "SCIONGEN")
GETTOTALIRN
TotalIRN = RESULT
do i = 1 to TotalIRN
if pgopen then Postmsg(,,"\\\"||i||" (of "||TotalIRN||")", "SCIONGEN")
EXISTPERSON i
/* Skip deleted persons */
if RESULT = 'YES' then
do
/* No longer needed in Scion v4; it always uses the English terms,
* "M", "F" and "?"
GETSEX i
sx = ConvertSex(RESULT)
if sx ~= "" then PUTSEX i sx
*/
GETBIRTHDATE i
datestr = ParseDate(RESULT)
if datestr ~= "" then PUTBIRTHDATE i datestr
GETBAPTISMDATE i
datestr = ParseDate(RESULT)
if datestr ~= "" then PUTBAPTISMDATE i datestr
GETDEATHDATE i
datestr = ParseDate(RESULT)
if datestr ~= "" then PUTDEATHDATE i datestr
GETBURIALDATE i
datestr = ParseDate(RESULT)
if datestr ~= "" then PUTBURIALDATE i datestr
end
end
if ~usereq then do
Tell("Done ("||TotalIRN||" persons parsed).")
/* Now the list of families... */
Tell("Parsing Family Details...")
end
else if pgopen then
Postmsg(,, "\\Processing family:\ ", "SCIONGEN")
GETTOTALFGRN
TotalFGRN = Result
do i = 1 to TotalFGRN
if pgopen then Postmsg(,, "\\\"||i||" (of "||TotalFGRN||")", "SCIONGEN")
EXISTFAMILY i
/* Skip deleted families */
if RESULT = 'YES' then do
GETMARRYDATE i
datestr = ParseDate(RESULT)
if datestr ~= "" then PUTMARRYDATE i datestr
GETENGAGEDATE i
datestr = ParseDate(RESULT)
if datestr ~= "" then PUTENGAGEDATE i datestr
GETENDDATE i
datestr = ParseDate(RESULT)
if datestr ~= "" then PUTENDDATE i datestr
end
end
if pgopen then do
Postmsg()
pgopen = 0
end
if usereq then do
rtezrequest('Scion Translation is ready.' || NL || 'Parsed '||,
TotalIRN||' persons and '||TotalFGRN||' families.',,'Translate Message:','rt_pubscrname = SCIONGEN')
end
else do
Tell("Done ("||TotalFGRN||" families parsed)."||NL)
end
EXIT
CheckAnswer: PROCEDURE EXPOSE outp usereq pgopen
parse arg str
if str < 0 | str > 10 then
TermError("Not a valid option: "||str||" -- program terminated.")
return str
ConvertSex: PROCEDURE EXPOSE lang
parse arg sxstr
if lang = '1' & sxstr = "V" then sxstr = "F"
else if lang = '2' & sxstr = "F" then sxstr = "V"
else if lang = '3' & sxstr = "W" then sxstr = "F"
else if lang = '4' & sxstr = "F" then sxstr = "W"
else if lang = '9' & sxstr = "F" then sxstr = "K"
else if lang = '10' & sxstr = "K" then sxstr = "F"
/* French and Italian: 'M' and 'F', same as in English */
else sxstr = ""
return sxstr
/* PARSEDATE SUBROUTINE */
/* For each word in the datestr string, see if it occurs in the datin
* string. If it does, replace it with the equivalent in the datout string
*/
ParseDate: PROCEDURE EXPOSE datin datout
parse arg datestr
datestr = strip(datestr); /* remove leading blanks */
if datestr = "" then return datestr
rdate = translate(datestr,' ','-/'); /* replace all '-' or '/' by ' ' */
datestr = upper(rdate)
/* keep rdate in its original case, so we don't accidentally change
* the case of any other words in the resulting
*/
cp = 1
/* check all words with the datin string */
do cnt = 1 to words(datestr)
cw = word(datestr, cnt)
num = find(datin, cw)
if num > 0 then do
rep = word(datout, num)
if rep="." then rep=""
rl = length(rep)
cl = length(cw)
cp = index(upper(rdate), cw, cp)
rdate = delstr(rdate, cp, cl)
rdate = insert(rep, rdate, cp-1)
end
end
return rdate
Tell: PROCEDURE EXPOSE outp
parse arg str
if outp then
writeln(stdout, str)
return 0
TellNN: PROCEDURE EXPOSE outp
parse arg str
if outp then
writech(stdout, str)
return 0
TermError: PROCEDURE EXPOSE outp usereq pgopen
parse arg str
/* If you turned off stdout, no error messages will be shown! */
if usereq then
rtezrequest(str,'E_xit','Translate Message:','rt_pubscrname = SCIONGEN')
else do
Tell(str || '0A'x)
end
if pgopen then Postmsg()
EXIT